package org.example;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class UserServiceProxy implements  UserService{

    private UserService userService;

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @Override
    public void add() {
        log("add()");
        userService.add();
    }

    @Override
    public void delete() {
        log("delete()");
        userService.delete();
    }

    @Override
    public void update() {
        log("update()");
        userService.update();
    }

    @Override
    public void query() {
        log("query()");
        userService.query();
    }

    public void log(String methodName) {
        // 创建一个Date对象来表示当前的日期和时间
        Date currentDate = new Date();
        // 设定输出日期时间的格式
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");

        System.out.println("[" + dateFormat.format(currentDate) + "]调用了核心业务逻辑方法：" + methodName);
    }
}
